package com.dexilaonian.adpter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dexilaonian.R;
import com.dexilaonian.bean.DocBean;

import java.util.List;

/*
 *  @项目名：  cmcc 
 *  @包名：    com.dexilaonian.adpter
 *  @文件名:   DocAdapter
 *  @创建者:   xuxing
 *  @创建时间:  2018/4/7 1:18
 *  @描述：    TODO
 */
public class DocAdapter extends BaseAdapter{
	private static final String TAG = "DocAdapter";
	private final Context mContext;
	private final List<DocBean> mDoc_list;


	public DocAdapter(Context context, List<DocBean> doc_list) {
		mContext = context;
		mDoc_list = doc_list;
	}

	@Override
	public int getCount() {
		return mDoc_list.size();
	}

	@Override
	public Object getItem(int i) {
		return mDoc_list.get(i);
	}

	@Override
	public long getItemId(int i) {
		return i;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			LayoutInflater inflater = LayoutInflater.from(mContext);
			convertView = inflater.inflate(R.layout.item_doc, null);
			holder.itemDoc= (TextView) convertView.findViewById(R.id.tv_item_doc);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		String name = mDoc_list.get(position).getName();
		holder.itemDoc.setText(name);
		return convertView;
	}

	class ViewHolder {
		TextView itemDoc;
	}
}
